Repository navigation
fix(studio): a sealed drag the preview never answers is refused, not saved wrong - #8720
Conversation
…nswered-press-refused
Edit accuracy: accurate 273 (base branch 271), smooth 60 of thoseThe gate passes. Newly passing (2)
Not banked yet, reported and not gated (bank a full-grid run's baseline.json) (2)
Quarantined, measured but not gated (0) |
jrusso1020
left a comment
There was a problem hiding this comment.
Reviewed at 3aba4d3
APPROVE. I found no blocking issues. A sealed press the frame never answers now ends the same way as a sealed nudge the frame never answers (useDomEditNudge.ts:300-303). Both go through the same askShownGestureStarts read, so they wait the same length of time: a 1 s agent probe, then the 5 s request timeout. Both show the same unansweredMoveReason text through the same onBlockedMoveRef, and neither starts an edit. The drag also draws its box back at the press. A regular (unsealed) preview never reaches this branch: startOnShownPreview starts at once when !channel (line 168), so the nudge is the right thing to match.
Late answers can't write onto anything newer, for three reasons:
- the port settles a timed-out request once and drops any later reply;
askShownFrameignores an answer for a frame it has stopped asking (askedOf !== frame, line 217);pollreturns as soon as the press has ended (line 247).
The removed "start from the drawn box" path was the only path that started a sealed drag with no snap targets and no GSAP start. Dropping it removes the wrong saves the PR describes.
Findings
Nit: a second press queued behind a refused press leaves the box off the layer (previewGestureStarts.ts:272, :354)
The second press takes its origin from overlayRectRef (line 354), and at that point the box is where the first drag drew it. When the first press is refused, the box is drawn back to the layer. When the second is refused, press.draw(0, 0) draws it back to the first drag's end instead.
Probe (scratch test with the file's own helpers, silentFrame()):
- Press with the box at
left: 1and draw it to+30. - Release, then press again while the first press still waits.
Both presses are refused, each with the message, and nothing starts. The box ends at {"left":31,...}, not left: 1. This is the off-layer box the second commit fixes, reached through a retry while the first press waits. The file is unchanged and the next answered press starts from the frame's read, so the effect is only visual.
Possible fix: when a refused press still has a press queued behind it, hand that press the refused press's draw-back. For example, unlink could carry the older press's origin forward. Or refuse the queued press too, since it was drawn from a drag that never happened. Fine as a follow-up.
Nit: the draw-back and the message depend on the current selection, not on the press (previewGestureStarts.ts:270-271)
sayWhyNotStarted returns early when opts.selectionRef.current is null. If the selection is cleared while the press waits, nothing is said and the box is left where it was drawn. The probe ended at left: 31 with 0 calls. With no selection the chrome is hidden, so this is invisible today. Still, press.draw?.(0, 0) doesn't need the selection, and for a single press the message could name the pressed target that startGesture already holds. Suggestion: move press.draw?.(0, 0) above the selection guard.
Pre-existing: askShownFrame's void askShownGestureStarts(...).then(...) has no .catch (previewGestureStarts.ts:211)
The nudge's copy has one (useDomEditNudge.ts:295). The read helpers don't reject today, because previewAnswer turns port errors into null, so nothing to do in this PR.
Other probes (all as expected)
- Group drag, frame silent: the message is shown once and the group boxes go back from
left: 31toleft: 1. No start. - Teardown mid-press (
endWaitingPress()while the read is pending, then wait 2.5 s): 0 messages, 0 starts, no unhandled rejection. The frame loop is cancelled inendWaitingPress, and the late answer hitspress.ended. - Frame swapped in after the first ask: the existing test
asks the frame shown again when a swap comes after its first askis green, so an answering frame still starts the press.
Test evidence
- Setup:
bun install --frozen-lockfile, then build parsers, lint, core and studio-server. - At head:
vitest run src/components/editor/previewOverlayRects.test.tsgave 29/29 passed. - Red first, with main's
previewGestureStarts.tscopied over the PR's copy and the PR's tests kept, 2 failed and 27 passed:refuses a press the frame never answers, saying why: Studio drew a box for itfailed withexpected "vi.fn()" to be called once, but got 0 times.puts Studio's box back on the layer when it refuses a press the frame never answersfailed the same way.
- On the first fix commit a62e390, the box test fails with
left: 31instead ofleft: 1, as the body says. - After restoring the file,
git status --porcelainshows only LFS fixture noise. - Related files at head: 12 files, 177/177 passed. They were previewOverlayRects, useDomEditNudge.sealed, gsapMoveSealedPreview, previewGestureStartRead, gestureHoldsPreviewReload, DomEditOverlay, domEditOverlayStartGesture (+blocked), dragUndoPaint, clickAfterPreventedPress, useDomEditNudge and groupDropKeepsSelection.
- CI: 59 pass, 22 skipping, none failing or pending.
Need: yes, a sealed drag the frame never answered saved keyframes 200 px off · Size: right, -12/+9 in one file plus tests · Reuse: good, the same askShownGestureStarts/UNANSWERED/unansweredMoveReason/onBlockedMoveRef path as the sealed nudge with no second timer, and the draw-back reuses press.draw · Simpler: yes, it removes the drawn callbacks and a step · Structure: fine, startsFrom now starts only on run
Risk: low — it only changes what happens when a sealed frame gives no usable answer, it now refuses instead of saving a wrong position, and an answered press is unchanged.
— Rames
What
When a sealed preview never answers a press on a layer, Studio now refuses the drag and says why ("The preview didn't answer, so Studio can't move this layer. Try again."), and puts its selection box back on the layer. Before, it started the drag from the box it had drawn and saved a wrong position for a layer whose position GSAP animates.
Why
On a sealed preview Studio can't read the pressed layer itself. A press asks the frame where the layer is, its GSAP position and what it can snap to. If the frame gave no usable answer (no reply in time, a malformed one, or a newly shown frame that never answers), #8492 started the drag anyway from the box Studio drew at the press. That drag had:
collectSnapContextreads the frame's document, which a sealed preview doesn't have;On the devbox, with sealed Studio's press reads to the frame dropped, dragging a box held at
y: 200saved its keyframes aty: 125.7andy: 0. A regular preview savesy: 325.7andy: 200for the same drag, so every keyframe was 200 px off. A regular preview never takes this path, since it reads the layer directly.A nudge on a sealed preview already refuses an unanswered frame with the same message (
components/editor/useDomEditNudge.ts:301-303). A drag now does the same.Related work
Refs #7846 (Studio's preview sealed by default). Partly undoes #8492's fallback for a frame that never answers. A press the frame does answer, including one held across a frame swap, starts as before.
How
components/editor/previewGestureStarts.ts:unansweredinstead ofdrawn.Test plan
refuses a press the frame never answers, saying why: Studio drew a box for itinsrc/components/editor/previewOverlayRects.test.tsfailed on main withexpected "vi.fn()" to be called once, but got 0 times: the press started from the drawn box and nothing said why. It replaces the two tests that pinned starting from the drawn box.puts Studio's box back on the layer when it refuses a press the frame never answersin the same file failed on the first fix commit with the box left 30 px off (left: 31instead ofleft: 1).on an opaque frame waits for what the gesture starts from, read in one request(same file) is unchanged and green.y: 200and an x keyframed tween. Select the box, drop Studio'squery,describeandgesture-startrequests to the frame, drag the box 150 px right and 60 px down, wait 8 s, readindex.html:y: 125.7/y: 0(200 px off)y: 325.7/y: 200Before
Sealed preview on main, frame silent: the drag went through and saved the box 200 px off its hold.
After
Sealed preview on this branch, frame silent: the drag is refused with the toast, the box and file are unchanged, and the selection box is back on the layer.
Regular preview, same drag, for comparison: